<?php
/**
 * This file is part of the Jindai.
 * @copyright Copyright (c) 2019 All Rights Reserved.
 * @author jindai <jindai0305@gmail.com>
 */

namespace App\Passport;

/**
 * Class ServerRequest
 * @package App\Passport
 */
class ServerRequest extends \Zend\Diactoros\ServerRequest
{
    private $append_parsed_body = [];

    /**
     * @param $data
     * @return $this
     */
    public function withAppendBody($data)
    {
        $this->append_parsed_body = $data;
        return $this;
    }

    /**
     * @inheritdoc
     */
    public function getParsedBody()
    {
        $parsedBody = parent::getParsedBody() ?: [];

        return array_merge($parsedBody, $this->append_parsed_body);
    }
}
